/**
 * Created by LeungZ on 2016/10/17.
 */
import imgTemp from './image.html';
import imgCtrl from './image.ctrl.js';

import './build/build.scss';
import buildTemp from './build/build.html';
import buildCtrl from './build/build.ctrl.js';

export default angular.module('ctg-k8sconsole').config(['$stateProvider', $stateProvider=> {
    $stateProvider.state('app-image', {
        url: '/app/image',
        templateUrl: imgTemp,
        controller: imgCtrl,
        controllerAs: 'list',
        resolve:{
            list:['appSrv', 'ctgNotification','$rootScope', function (appSrv, ctgNotification,$rootScope) {
                return appSrv.getBuildList({currentPage: 1,sysUserCode:JSON.parse(localStorage.getItem('myUser')),imageType:$rootScope.imageType?$rootScope.imageType:'000'}).catch(function (data) {
                    ctgNotification.error('获取构建列表数据有误.');
                });
            }]
        }
    }).state('app-image-build', {
        url: '/app/image/build',
        templateUrl: buildTemp,
        controller: buildCtrl,
        controllerAs: 'vm',
        resolve:{
            baseImgList:['imageSrv', 'ctgNotification','$rootScope', function (imageSrv, ctgNotification, $rootScope) {
                return imageSrv.getHarborImages({sysUserCode:$rootScope.user.sysUserCode,imageType:'001',page:99,currentPage:1}).catch(function (data) {
                    ctgNotification.error('获取基础镜像列表数据有误.');
                });
            }]
        }
    })
}]);